import 'package:bilibili_getx_project/ui/shared/app_theme.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:video_player/video_player.dart';

import 'video_player_example_logic.dart';

class VideoPlayerExampleView extends StatelessWidget {
  final logic = Get.find<VideoPlayerExampleLogic>();
  final state = Get.find<VideoPlayerExampleLogic>().state;
  static String routeName = "/videoPlayer";

  @override
  Widget build(BuildContext context) {
    return GetBuilder<VideoPlayerExampleLogic>(builder: (logic) {
      return Scaffold(
        body: Center(
          child: state.videoPlayerController.value.isInitialized
              ? !state.openMiniWindow
                  ? AspectRatio(
                      aspectRatio:
                          state.videoPlayerController.value.aspectRatio,
                      child: VideoPlayer(
                        state.videoPlayerController,
                      ),
                    )
                  : Container(
                      color: AppTheme.norBlack,
                    )
              : Container(),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            logic.createMiniWindowVideo(context);
          },
          child: Icon(
            Icons.desktop_windows,
          ),
        ),
      );
    });
  }
}
